﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameSweets:MonoBehaviour {
    //位置
    private int x;

    public int X
    {
        get
        {
            return x;
        }
        set
        {
            if (CanMove())
            {
                x = value;
            }
        }
    }

    public int Y
    {
        get
        {
            return y;
        }
        set
        {
            if (CanMove())
            {
                y = value;
            }
        }

    }

    private int y;

    //种类
    private GameManager.SweetsType type;

    public GameManager.SweetsType Type
    {
        get
        {
            return type;
        }
    }

    public MoveSweet m_MoveSweet
    {
        get
        {
            return moveSweet;
        }

       
    }

    private MoveSweet moveSweet;

    private ClearSweet clearSweet;
    public ClearSweet m_ClearSweet
    {
        get
        {
            return clearSweet;
        }
    }

    private ColorSweet colorSweet;
    public ColorSweet m_ColorSweet
    {
        get
        {
            return colorSweet;
        }
    }

  

    //[HideInInspector]
    //public GameManager gm;
    public bool CanMove()
    {
        return moveSweet != null;
    }

    public bool CanColor()
    {
        return colorSweet != null;
    }

    public bool CanClear()
    {
        return clearSweet != null;
    }

    
    private void Awake()
    {
        moveSweet = GetComponent<MoveSweet>();
        colorSweet = GetComponent<ColorSweet>();
        clearSweet = GetComponent<ClearSweet>();
       
    }

    public void Init(int _x,int _y,GameManager.SweetsType _type)
    {
        x = _x;
        y = _y;
        type = _type;
    }

    public void OnMouseEnter()
    {
        GameManager.Instance.OnEnterSweet(this);
    }
    public void OnMouseDown()
    {
        GameManager.Instance.OnPressSweet(this);
    }
    public void OnMouseUp()
    {
        GameManager.Instance.OnReleaseSweet();
    }
}
